package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupOrderCustomer;

/**
 * Denne klasse bruges til at hente al data i bs_order_customer og returnere det
 * @author junjie
 */
public abstract class BackupOrderCustomerHandler {
    /**
     * Hente alle rækker i bs_order_customer og returnere et BackupOrderCustomer[] model
     * @return BackupOrderCustomer[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
    public static BackupOrderCustomer[] getBackupOrderCustomers() throws ClassNotFoundException, SQLException{
        BackupOrderCustomer[] backupOrderCustomers = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_order_customer", "", "", "", "fk_order_id", "fk_customer_id", "order_or_payer");
        backupOrderCustomers = new BackupOrderCustomer[result.length];
        
        db.closeDB();
        
        for (int i = 0; i < result.length; i++) {
            backupOrderCustomers[i] = new BackupOrderCustomer(Integer.parseInt(result[i][0]), Integer.parseInt(result[i][1]), Integer.parseInt(result[i][2]));
        }
        return backupOrderCustomers;
    }
}
